<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
	<head>
		<title>Ruby Library Manager</title>
		<%= stylesheet_link_tag "admin" %>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script type="text/javascript">
			function checkDelBoxes(parent) {
				var input = document.getElementsByTagName("input");
				for (var i = 0; i < input.length; i++)
					if (input[i].type == "checkbox") {
						input[i].checked = parent;
					}
			}

			function countSelect() {
				var input = document.getElementsByTagName("input");
				var count = 0;
				for (var i = 0; i < input.length; i++)
					if (input[i].type == "checkbox") {
						if (input[i].checked)
							count++;
					}
				return count;
			}
		</script>

	</head>

	<body>
		<!-- Header of the page -->
		<!-- Your should use ruby code to include header file here, default html can not include file -->
		<div id="header">
			<div id="header_infos">
				<span id="header_shopname"> <span>Ruby Library Manager</span> </span>
				<span id="employee_links"> <span class="employee_name">Trang Quản lí</span> <span class="separator"></span> <a id="header_logout" href="/logout"> <span>Thoát</span> </a> </span>

			</div>
			<ul id="menu">
				<li id="maintab0" class="submenu_size maintab">
					<span class="title"> <%= image_tag "home-icon.png", :alt => "", :height => 20%> <a style="color:white" href="/admin/home"> Trang chủ </a> </span>
				</li>
				<li id="maintab1" class="submenu_size maintab">
					<span class="title"> <%= image_tag "try-product.png", :alt => "", :height => 20%> <a style="color:white" href="/admin/book"> Sách</a> </span>
				</li>
				<li id="maintab2" class="submenu_size maintab">
					<span class="title"> <%= image_tag "try-category.png", :alt => "", :height => 20%> <a style="color:white" href="/admin/categories"> Danh mục </a> </span>
				</li>
				<li id="maintab3" class="submenu_size maintab">
					<span class="title"> <%= image_tag "try-customer.png", :alt => "", :height => 20%> <a style="color:white" href="/admin/user"> Tài khoản </a> </span>
				</li>
				<li id="maintab4" class="submenu_size maintab">
					<span class="title"> <%= image_tag "try-auction.gif", :alt => "", :height => 20%> <a style="color:white" href="/admin/borrow"> Mượn sách </a> </span>
				</li>
			</ul>
		</div>
		<!-- Admin Book content -->
		<div id="login">
			<div class="clear"></div>
			<div id="admin_content">
				<div class="toolbarBox">
					<div style="float:left;">
						<h3 style="font-size:18px;margin-left:10px;font-weight: normal;">Mượn Sách</h3>
					</div>
				</div>

				<div style="text-align:left;font-weight:bold;font-size:13px">
					Tổng cộng có <span style="color:red"><%= Book.all.count %></span> sách, hiển thị trong <span style="color:red"><%= @borrows.num_pages %></span> trang.
				</div>
				<br/>
				<div class="pagination" style="float:left">
                  <%= paginate @borrows %>
				</div>
				<div class="clear"></div>
				<br/>
				<form>

					<table id="product" class="table product" cellspacing="0" cellpadding="0" style="width: 100%; margin-bottom:10px;margin-left:auto;margin-right:auto">
						<colgroup>

							<col width="100px">
							<col width="70px">
							<col width="70px">
							<col width="70px">
							<col width="70px">
							<col width="50">
							<col width="50">
							<col>
						</colgroup>
						<thead>
							<tr style="height:40px;">
								<th class="center"><a href=""> Tên sách</a></th>

								<th class="center"> Người mượn </th>

								<th class="center"> Tình trạng </th>

								<th class="center"> Ngày mượn </th>

								<th class="center"> Ngày trả </th>

								<th class="center"> Nhắc nhở </th>

								<th class="center"> Trả sách </th>

							</tr>
						</thead>
                      <% for item in @borrows %>
						<tr class="row_hover">
							<td class="pointer center"> <%= item.book.name %> </td>
							<td class="pointer center"> <%= item.user.name %> </td>

							<td class="pointer center"> <% if item.is_return%>
							Đã trả
							<% else %>
							<% if item.created_at + 7.days < Date.today%>
							Quá hạn
							<% else %>
							Đang mượn
							<% end %>
							<% end %> </td>

							<td class="pointer center"> <%= item.created_at %> </td>

							<% if item.is_return?%>
							<td class="pointer center"> <%= item.updated_at %> </td>
							<% else %>
							<td class="pointer center"> Chưa </td>
							<% end %>

							<td class="pointer center"> <%= button_to 'Nhắc nhở', admin_remind_path(:item => item, :path => request.url)%> </td>

							<td class="pointer center"> <%= button_to 'Trả sách', admin_return_path(:item => item, :path => request.url)%> </td>
						</tr>
						<% end %>
					</table>
				</form>

			</div>
		</div>
	</body>
</html>

